#include <rtl/print.h>
#include "io.h"

#define EFUSE_SECCFG (0x10206060)

#define EFUSE_SECCFG_HW_JTAG_DISABLED (1)
#define EFUSE_SECCFG_SBC (1 << 1)
#define EFUSE_SECCFG_DAA (1 << 2)
#define EFUSE_SECCFG_SLA (1 << 3)
#define EFUSE_SECCFG_SW_JTAG_ENABLED (1 << 6)
#define EFUSE_SECCFG_BROM_LOCK_DISABLED (1 << 9)

VOID AgpPrintEfuseState()
{
    UINT32 Reg = READ32(EFUSE_SECCFG);

    RtlPrintf("[EFUSE] HW JTAG:        %s %s\n", (Reg & EFUSE_SECCFG_HW_JTAG_DISABLED) ? "Disabled" : "Enabled ", (Reg & EFUSE_SECCFG_HW_JTAG_DISABLED) ? "BLOWN" : "");
    RtlPrintf("[EFUSE] SW JTAG:        %s %s\n", (Reg & EFUSE_SECCFG_SW_JTAG_ENABLED) ? "Enabled " : "Disabled", (Reg & EFUSE_SECCFG_SW_JTAG_ENABLED) ? "BLOWN" : "");
    RtlPrintf("[EFUSE] SBC:            %s %s\n", (Reg & EFUSE_SECCFG_SBC) ? "Enabled " : "Disabled", (Reg & EFUSE_SECCFG_SBC) ? "BLOWN" : "");
    RtlPrintf("[EFUSE] DAA:            %s %s\n", (Reg & EFUSE_SECCFG_DAA) ? "Enabled " : "Disabled", (Reg & EFUSE_SECCFG_DAA) ? "BLOWN" : "");
    RtlPrintf("[EFUSE] SLA:            %s %s\n", (Reg & EFUSE_SECCFG_SLA) ? "Enabled " : "Disabled", (Reg & EFUSE_SECCFG_SLA) ? "BLOWN" : "");
    RtlPrintf("[EFUSE] JTAG BROM LOCK: %s %s\n", (Reg & EFUSE_SECCFG_BROM_LOCK_DISABLED) ? "Disabled" : "Enabled ", (Reg & EFUSE_SECCFG_BROM_LOCK_DISABLED) ? "BLOWN" : "");
    RtlPrintf("[EFUSE] Public key hash:\n");
    for (INT I = 0; I < 8; I++) {
	RtlPrintf("[EFUSE]    0x%08x\n", READ32(0x10206090 + (I * 4)));
    }
}
